<template>
<div>
  <div style="flex: 1;float: left;">
    <span :class="collapseBtnClass" style="cursor: pointer; color:#ffffff; font-size: 20px" @click="collapse"></span>
    <el-breadcrumb separator="/" style="display: inline-block; margin-left: 10px; font-size: 15px">
      <el-breadcrumb-item :to="{path: 'home', name: 'Home', component: () => import('../views/system/Home.vue')}"><span style="color: #ffffff">首页</span></el-breadcrumb-item>
      <el-breadcrumb-item><span style="color: #ffffff">{{ currentPathName }}</span></el-breadcrumb-item>
    </el-breadcrumb>
  </div>
  <el-dropdown style="width: 125px;float: right;cursor: pointer">
    <div>
      <img :src="user.avatar" alt=""
           style="width: 30px; border-radius: 150%; position: relative; top: 10px; right: 5px">
      <span style="margin-right: 5px;color: white">{{ user.nickname }}</span>
      <i class="el-icon-arrow-down" style="color: white"></i>
    </div>
    <el-dropdown-menu slot="dropdown" style="margin-right: 35px;width: 90px;text-align: center;">
      <el-dropdown-item><router-link to="/person"><span style="text-decoration: none">个人信息</span></router-link></el-dropdown-item>
      <el-dropdown-item>
        <span style="text-decoration: none" @click="logout">退出</span>
        </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</div>
</template>

<script>
export default {
  name: "Header",
  props: {
    collapseBtnClass: String,
    collapse: Function,
    user: Object
  },
  data() {
    return {
      // user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}
    }
  },
  methods: {
    logout() {
      this.$router.push("/login")
      localStorage.removeItem("user")
      this.$message.success("退出成功")
    }
  },
  computed: {
    currentPathName () {
      return this.$store.state.currentPathName;　　//需要监听的数据
    }

  },
}
</script>

<style scoped>

</style>